# -*- coding: utf-8 -*-
# @Date：2024/9/30 11:51:01
# @Author：CJiaの青姝
# @FileName：models
# @Editor：PyCharm2024
# @Remark：
from django.db import models
from config.constants import STATUS_CHOICES
from utils.cj_jwt import DateTimeFieldFormat


class CoreModel(models.Model):
    """
    核心标准抽象模型模型,可直接继承使用
    增加审计字段, 覆盖字段时, 字段名称请勿修改, 必须统一审计字段名称
    """
    id = models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='主键ID',
                          help_text="主键ID")
    sort = models.IntegerField(default=1, null=True, blank=True, verbose_name="显示排序", help_text="显示排序")
    creator = models.CharField(max_length=255, null=True, blank=True, verbose_name='创建人', help_text="创建人")
    modifier = models.CharField(max_length=255, null=True, blank=True, help_text="修改人", verbose_name="修改人")
    belong_dept = models.IntegerField(default=None, null=True, blank=True, verbose_name="数据归属部门",
                                      help_text="数据归属部门")
    remark = models.CharField(max_length=255, default=None, null=True, blank=True, verbose_name="备注",
                              help_text="备注")
    status = models.BooleanField(choices=STATUS_CHOICES, default=True, verbose_name="状态", help_text="状态")
    create_time = DateTimeFieldFormat(null=True, blank=True, auto_now_add=True, editable=True,
                                      verbose_name="创建时间", help_text="创建时间")
    update_time = DateTimeFieldFormat(null=True, blank=True, auto_now=True, editable=True,
                                      verbose_name="修改时间", help_text="修改时间")

    class Meta:
        abstract = True
        verbose_name = '核心模型'
        verbose_name_plural = verbose_name
